import { createApp } from 'vue';
import pinia from '/@/stores/index';
import App from './App.vue';
import router from './router';
import { directive } from '/@/utils/directive';
import { i18n } from '/@/i18n/index';
import other from '/@/utils/other';

import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import '/@/theme/index.scss';
import mitt from 'mitt';
import VueGridLayout from 'vue-grid-layout';
import { useErrorInfo } from '/@/stores/errorInfo';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
// import { storeToRefs } from 'pinia';
import EnumOptions from '/@/components/Linxyun/Datas/enum_options.js';
import registerModule from './components/Linxyun/element/CustomExted';

registerModule();
EnumOptions.instance().loadEnumOptions();
const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component);
}
directive(app);
other.elSvg(app);

app.use(pinia).use(router).use(ElementPlus, { i18n: i18n.global.t }).use(i18n).use(VueGridLayout).mount('#app');

app.config.globalProperties.mittBus = mitt();
app.config.errorHandler = (err, vm, info) => {
	console.error('[全局异常]', err, vm, info);
};
// 初始化错误码信息
let errInfo = new Map<string, string>();
errInfo.set('1006', '用户不存在或密码不匹配');
errInfo.set('204', '参数错误');
errInfo.set('240', 'URI不存在')
errInfo.set('241', 'URI已经存在')
errInfo.set('200', '参数错误');
errInfo.set('320', '服务的路由异常，请联系管理员');
errInfo.set('998', '处理超时，服务配置出错，请联系管理员');
errInfo.set('9998', '登录超时，请重新登录');
errInfo.set('401', '登录超时，请重新登录');
errInfo.set('1005', '操作失败');
errInfo.set('1007', '用户已经存在');
errInfo.set('1008', '操作ID配置错误，请联系管理员');
errInfo.set('1009', '用户ID参数错误');
errInfo.set('1010', '用户不存在或密码不匹配');
errInfo.set('1011', '用户邮箱地址错误');
errInfo.set('1012', '邮箱地址已经存在');
errInfo.set('1013', '手机号码格式不正确');
errInfo.set('1014', '手机号码已经存在');
errInfo.set('1020', '登录验证出错');
errInfo.set('1021', '用户没有登录');
errInfo.set('1022', '用户状态不正常');
errInfo.set('1023', '发送验证码失败');
errInfo.set('1024', '验证码验证失败');
errInfo.set('1030', '用户组已经存在');
errInfo.set('1031', '用户组不经存在');
errInfo.set('1999', '操作出错');
errInfo.set('886000', '前端处理验证数据出错');
errInfo.set('2012','请先删除内容')
const storesErrorInfo = useErrorInfo();
// const { errorInfo } = storeToRefs(storesErrorInfo);
storesErrorInfo.setErrorInfo(errInfo);
// console.log('errorInfo', errorInfo.value);
